#ifndef __LINKTREE_H_
#define __LINKTREE_H_

#define TreeElementType char*
#include <stdbool.h>
#include "DoubleLinkList.h"

struct TreeNode;
typedef struct TreeNode TNode;

//创建树节点
TNode *CreateTreeNode(TreeElementType element);
//销毁树节点
void FreeTreeNode(void *n);
//获取节点数据域
void *GetTreeNodeData(TNode* node);

//连接
void ConnectBranch(TNode *parent,TNode *child);
//断开
void DisconnectBranch(TNode *parent,TNode *child);
//遍历树
void TravelTreeNode(TNode *node,int deepth,void(*funcPtr)(void*));
//查找某个节点的某个孩子
TNode *FindChildNode(TNode *parent,void* value,bool(*funcPtr)(void *,void *));


struct LinkTree;
typedef struct LinkTree LTree;

//初始化一个树
LTree *InitLinkTree();
//获取树的根节点
TNode *GetTreeRoot(LTree *tree);
//获取树高
int GetTreeHeight(LTree *tree);
//打印树
void TravelTree(LTree *tree,void(*funcPtr)(void*));

//查找节点
TNode* FindLinkTreeNode(LTree *tree,void* value,bool(*funcPtr)(void *,void *));

//找到所有的叶子节点
DLlist FindAllLeafBranches(LTree *tree);
//释放整个树
void ClearLinkTree(void *tree);

#endif